<template>
  <section class="searchForm">
    <el-form
      :model="searchFragForm"
      ref="searchFragForm"
      label-width="100px"
      :inline="true"
    >
      <el-form-item label="碎片ID" prop="fragID">
        <el-input
          type="worldID"
          v-model="searchFragForm.fragID"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item label="碎片名称" prop="fragName">
        <el-input
          type="fragName"
          v-model="searchFragForm.fragName"
          autocomplete="off"
        ></el-input>
      </el-form-item>

    <el-form-item label="世界名称" prop="worldName">
        <el-input
          type="worldName"
          v-model="searchFragForm.worldName"
          autocomplete="off"
        ></el-input>
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          @click="submitForm('searchFragForm')"
          class="search-btn"
          >查询</el-button
        >
        <el-button @click="resetForm('searchFragForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </section>
</template>

<script>
export default {
  data() {
    return {
      searchFragForm: {
        fragID: "",
        fragName: "",
        worldName: "",
      },
    };
  },
  methods: {
    submitForm(formName) {
      alert(formName);
      this.$refs[formName].validate((valid, form) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>
<style lang="scss" scoped>
.searchForm {
  width: 100%;
  background: #fff;
  border-radius: 4px;
  box-sizing: border-box;
  min-height: 60px;
  margin-bottom: 20px;
  .el-form-item {
    margin-top: 10px;
    margin-bottom: 10px;
    .el-input {
      width: 240px;
    }
  }
  .search-btn {
    margin-left: 60px;
  }
  .btns {
    padding-bottom: 10px;
  }
}
</style>
